package com.ku.order.controller;

import com.ku.order.client.UserApiClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping(value = "api/order")
@Slf4j
@Api(tags="订单管理")
public class OrderController {

    @Resource
    private UserApiClient userApiClient;
    @Resource
    private HttpServletRequest request;
    @ApiOperation("订单服务检测")
    @GetMapping("index")
    public String index(){
        String token = request.getHeader("token");
        return "Order Service";
    }

    @ApiOperation("订单->用户服务检测")
    @GetMapping("index/user")
    public String indexUser(){
        String token = request.getHeader("token");
        String userStr = userApiClient.index();
        log.info("调用用户服务返回结果===>{}",userStr);
        return userStr;
    }
}
